#include "CPlayer.h"
 
CPlayer::CPlayer()
{
    CEntity::Col_X = 8;
    CEntity::Col_Width = 15;
    CEntity::Type = ENTITY_TYPE_PLAYER;
    
}
 
bool CPlayer::OnLoad(char* File, int Width, int Height, int MaxFrames)
{
    if(CEntity::OnLoad(File, Width, Height, MaxFrames) == false)
    {
        return false;
    }
    return true;
}
 
void CPlayer::OnLoop()
{
    CEntity::OnLoop();
}
 
void CPlayer::OnRender(SDL_Surface* Surf_Display)
{
    CEntity::OnRender(Surf_Display);
}
 
void CPlayer::OnCleanup()
{
    CEntity::OnCleanup();
}
 
void CPlayer::OnAnimate()
{
    if(MoveLeft)
    {
        CEntity::CurrentFrameCol = 0;
    }
    else if(MoveRight)
    {
        CEntity::CurrentFrameCol = 1;
    }
    
    if(SpeedX != 0)
    {
        Anim_Control.MaxFrames = 8;
    }
    else
    {
        Anim_Control.MaxFrames = 0;
    }
 
    CEntity::OnAnimate();
}
 
bool CPlayer::OnCollision(CEntity* Entity)
{
    if(Entity->Type == ENTITY_TYPE_ENEMY)
    {
        if((Y + Height) < (Entity->Y + Entity->Height/2))
        {
            CEntity::SpeedY = -CEntity::MaxSpeedY;
        }
    }
    return true;
}